package com.itheima.edu.info.manager.day13;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) {



        hanbao();

        // Thread();

      //  callable();//只会执行一个线程


        //  synchronizedTest();//出票

        //   Runnable();

    }

    //一做一吃汉堡多线程实验
    private static void hanbao() {
        ChiHanBao chiHanBao=new ChiHanBao();
        ZuoHanBao zuoHanBao=new ZuoHanBao();
        Thread td=new Thread(chiHanBao);
        Thread td1=new Thread(zuoHanBao);
        td.start();
        td1.start();
    }

    //Calladle多线程测试
    private static void callable() {
        CallableTest cb=new CallableTest();
        FutureTask<String> ft= new FutureTask<>(cb);
        Thread td=new Thread(ft);
        Thread td1=new Thread(ft);
        Thread td2=new Thread(ft);
        td.setName("001");
        td1.setName("002");
        td2.setName("003");
        td.start();
        td1.start();
        td2.start();
    }

    //出票实验+线程锁测试
    private static void synchronizedTest() {
        synchronizedTest st=new synchronizedTest();
        Thread td=new Thread(st);
        Thread td1=new Thread(st);
        td.setName("窗口1");
        td1.setName("窗口2");
        td.start();
        td1.start();
    }

    //Runnable多线程测试
    private static void Runnable() {
        RunnableTest rt=new RunnableTest();
        Thread td=new Thread(rt);
        Thread td1=new Thread(rt);
        td.start();
        td1.start();
    }

    //Thread多线程测试
    private static void Thread() {
        ThreadTest tt=new ThreadTest();
        ThreadTest tt1=new ThreadTest();
        tt.start();
        tt1.start();
    }


}
